package org.tio.sitexxx.service.service.qj;

import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tio.sitexxx.service.model.main.Promoter;
import org.tio.sitexxx.service.model.main.Promotion;
import org.tio.sitexxx.service.vo.Const;

public class PromoterService {
    public  PromoterService(){

    }
    private static Logger log	= LoggerFactory.getLogger(PromoterService.class);
    public static final PromoterService me	= new PromoterService();
    final Promoter dao	= new Promoter().dao();
    /**
     * 保存数据
     * @param demo
     * @return
     */
    public boolean save(Promotion demo) {
        return demo.save();
    }

    /**
     * 修改数据
     * @param demo
     * @return
     */
    public boolean update(Promoter demo) {
        return demo.update();
    }
    /**
     * 查找推广者
     */
    public Promoter findPromoter(String mobile){
        //findPromoter
        String sqlid = "promoter.findPromoter";
        String db = Const.Db.TIO_SITE_MAIN;
        SqlPara sqlPara = Db.use(db).getSqlPara(sqlid,mobile);
        Promoter promoter = Promoter.dao.findFirst(sqlPara.getSql(), mobile);
      if(promoter==null){
          return null;
      }
      System.out.println("promoter:"+promoter);
      return promoter;
    }
}
